home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / TRIMLINE.AML < prev    next >
Text File  |  1996-07-17  |  1KB  |  39 lines

  1. //--------------------------------------------------------------------
  2. // TRIMLINE.AML
  3. // Trim Trailing Blanks and Tabs, (C) 1993-1996 by nuText Systems
  4. //
  5. // This macro trims trailing blanks and tabs from lines in the current
  6. // file. The operation is limited to a marked block if it exists. The
  7. // number of lines trimmed is displayed.
  8. //
  9. // Usage:
  10. //
  11. // Select this macro from the Macro List (on the Macro menu), or run it
  12. // from the macro picklist <shift f12>
  13. //--------------------------------------------------------------------
  14.  
  15. // compile time macros and function definitions
  16. include bootpath "define.aml"
  17.  
  18. // test for edit windows
  19. if not wintype? "edit" then
  20.   msgbox "Edit windows only!"
  21.   return
  22. end
  23.  
  24. // test if a marked block exists in the current file
  25. block_count = mark? and getmarkbuf == getcurrbuf
  26.  
  27. // display message
  28. say "Trimming lines" + (if? block_count " in block") + "..."
  29.  
  30. // find trailing whitespace using regular expression searching
  31. count = replace "{ |\x09}+$" '' "axg" + (if? block_count 'b')
  32.  
  33. // clear the title bar
  34. display
  35.  
  36. // display the number of lines trimmed
  37. shortbox  (if? count (thousands count) "No") + " lines trimmed" +
  38.           (if? block_count " in the block")
  39.